
clear matrix
set more off

*Load cleaned data
	use "Trieu2023_replication_file.dta"

	count
	bys treatment: count

*Set styel for graph
	set scheme s1mono
	grstyle init
	grstyle set plain, nogrid
	

//Correlation between performance in the Arithmetic task and the Grid task______
	pwcorr correctT1 correctT5, sig
	
//______________________________________________________________________________
//Section 4.1. EFFICIENCY_______________________________________________________
//______________________________________________________________________________

	*Note: Results reported in Appendix B.1.
	
	*Compulsory competition: Performance of winners in stage 2 
		bys treatment: sum correctT2 if WINT2_ALL==1
		ranksum correctT2 if(WINT2_ALL==1 & treatment == 1) | (WINT2_ALL==1 & treatment == 2),by(treatment)
		ranksum correctT2 if(WINT2_ALL==1 & treatment == 1) | (WINT2_ALL==1 & treatment == 3),by(treatment)
		ranksum correctT2 if(WINT2_ALL==1 & treatment == 2) | (WINT2_ALL==1 & treatment == 3),by(treatment)
		kwallis correctT2 if WINT2_ALL==1, by(treatment)
	
	*Self-selected competition: Performance in s1 and s3 of subject self-select into tournament
		*Figure B.1
			graph box correctT1 correctT3 if choiceT3==1, over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  ytitle ("Number of correct answers") // Left panel: performance of stage 3 winners
			graph box correctT1 correctT3 if WINT3_ALL==1, over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  ytitle ("Number of correct answers") // Right panel: performance of stage 3 candidate pool
		
		*Figure B.1 notes
			bys treatment: sum correctT1 correctT3 if choiceT3==1
			
			ranksum correctT1 if (choiceT3==1 & treatment == 1) | (choiceT3==1 & treatment == 2), by(treatment)
			ranksum correctT1 if  (choiceT3==1 & treatment == 1) | (choiceT3==1 & treatment == 3), by(treatment)
			ranksum correctT1 if  (choiceT3==1 & treatment == 2) | (choiceT3==1 & treatment == 3), by(treatment)

			ranksum correctT3 if (choiceT3==1 & treatment == 1) | (choiceT3==1 & treatment == 2), by(treatment)
			ranksum correctT3 if  (choiceT3==1 & treatment == 1) | (choiceT3==1 & treatment == 3), by(treatment)
			ranksum correctT3 if  (choiceT3==1 & treatment == 2) | (choiceT3==1 & treatment == 3), by(treatment)

			kwallis correctT1 if choiceT3==1, by(treatment)
			kwallis correctT3 if choiceT3==1, by(treatment)
			
			
			bys treatment: sum correctT1 correctT3 if WINT3_ALL==1
			
			ranksum correctT1 if (WINT3_ALL==1 & treatment == 1) | (WINT3_ALL==1 & treatment == 2), by(treatment)
			ranksum correctT1 if  (WINT3_ALL==1 & treatment == 1) | (WINT3_ALL==1 & treatment == 3), by(treatment)
			ranksum correctT1 if  (WINT3_ALL==1 & treatment == 2) | (WINT3_ALL==1 & treatment == 3), by(treatment)

			ranksum correctT3 if (WINT3_ALL==1 & treatment == 1) | (WINT3_ALL==1 & treatment == 2), by(treatment)
			ranksum correctT3 if  (WINT3_ALL==1 & treatment == 1) | (WINT3_ALL==1 & treatment == 3), by(treatment)
			ranksum correctT3 if  (WINT3_ALL==1 & treatment == 2) | (WINT3_ALL==1 & treatment == 3), by(treatment)

			kwallis correctT1 if WINT3_ALL==1, by(treatment)
			kwallis correctT3 if WINT3_ALL==1, by(treatment)
	
		*Performance in stage 1
			bys treatment: sum correctT1
			ranksum correctT1 if  treatment == 1 | treatment == 2, by(treatment)
			ranksum correctT1 if  treatment == 1 | treatment == 3, by(treatment)
			ranksum correctT1 if  treatment == 2 | treatment == 3, by(treatment)
			
		*Difference in performance when moving from piece rate to  tournament
			bys treatment: sum correctT1 correctT2 correctT3
			
			signrank correctT1=correctT2 if treatment==1
			signrank correctT1=correctT2 if treatment==2
			signrank correctT1=correctT2 if treatment==3
		
		*Gender difference in stage 1 and stage 2 performance
			bys gender: sum correctT1 correctT2

			ranksum correctT1 if gender==0 | gender==1 , by(gender)
			ranksum correctT2 if gender==0 | gender==1 , by(gender)
			
			bys treatment gender: sum correctT1 correctT2
			
			ranksum correctT1 if (gender==0 & treatment == 1) | (gender==1 & treatment == 1), by(gender)
			ranksum correctT1 if  (gender==0 & treatment == 2) | (gender==1 & treatment == 2), by(gender)
			ranksum correctT1 if  (gender==0 & treatment == 3) | (gender==1 & treatment == 3), by(gender)
			
			ranksum correctT2 if (gender==0 & treatment == 1) | (gender==1 & treatment == 1), by(gender)
			ranksum correctT2 if  (gender==0 & treatment == 2) | (gender==1 & treatment == 2), by(gender)
			ranksum correctT2 if  (gender==0 & treatment == 3) | (gender==1 & treatment == 3), by(gender)
			
		*Figure B.2
			graph box correctT1 correctT2, over(gender,relabel(0 "Women" 1 "Men")) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  ytitle ("Number of correct answers")
		
	
//______________________________________________________________________________
//Section 4.2. WILLINGNESS TO COMPETE___________________________________________
//______________________________________________________________________________
	
	//Section 4.2.1 Willingness to compete at the aggregate level
		
		*Figure 1
			graph dot choiceT3_p choiceT4_p , vertical over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  yscale (range(0(10)100)) nofill ytitle ("Percentage") // Left panel
			graph dot choiceT3_p choiceT4_p if treatment!=2, vertical over(type , relabel(1 "F_G" 2 "F_B" 3 "M_G" 4 "M_B")) //
				  over(treatment , relabel(1 "CTR" 3 "MIX")) ytitle ("Percentage") yscale (range(0(10)100)) // Right panel
	
		*Selection into tournament across treatments and types
			*Note: Results reported in Appendix B.3.1.
	
			bys treatment: sum choiceT3_p choiceT4_p if gender==0
			tab choiceT3 treatment if gender==0 & (treatment == 1 | treatment == 2), exact
			tab choiceT3 treatment if gender==0 & (treatment == 1 | treatment == 3), exact
			tab choiceT3 treatment if gender==0 & (treatment == 2 | treatment == 3), exact
			
			bys treatment: sum choiceT3_p choiceT4_p if gender==1
			
			tab choiceT3 gender if treatment==1 & (gender == 0 | gender == 1), exact
			tab choiceT4 gender if treatment==1 & (gender == 0 | gender == 1), exact
			
			tab choiceT3 treatment if gender==1 & (treatment == 1 | treatment == 3), exact
			tab choiceT3 treatment if gender==1 & (treatment == 2 | treatment == 3), exact
			tab choiceT3 treatment if gender==1 & (treatment == 1 | treatment == 2), exact
			

	//Section 4.2.2 Willingness to compete at the individual level
	
		*Table 1 and Table B.1: Willingness to compete at the individual level
			*Specification 1:
				probit choiceT3 genderq mixq beliefT3 
				margins, dydx(*)
				eststo mT3_1: margin, dydx(*) post
			*Specification 2: 
				probit choiceT3 genderq mixq beliefT3 risk fairness CRT_belief goodinmath
				margins, dydx(*)
				eststo mT3_2: margin, dydx(*) post
			*Specification 3:
				probit choiceT3 genderq mixq genderq_favT3 mixq_favT3 favoredT3 beliefT3 risk fairness CRT_belief goodinmath
				margins, dydx(*) 
				eststo mT3_3 :margin, dydx(*) post
			*Specification 4 (only in Table B.1):
				probit choiceT3 genderq mixq genderq_favT3 mixq_favT3 favoredT3 beliefT3 risk risk_favT3 fairness CRT_belief goodinmath, robust
				margins, dydx(*)
				test risk+risk_favT3=0
				eststo mT3_4 :margin, dydx(*) post
				
			*Export tables
				*cd "xxx\Tables"
				*Export Table 1
					esttab mT3_1 mT3_2 mT3_3	///
					   using probitWTC_short.tex, ///
					   keep(genderq mixq genderq_favT3 mixq_favT3 favoredT3 beliefT3 risk) ///
						label									///
						varlabels(								///
						  genderq "\quad GQ"					///
						  mixq "\quad MIX "					///
						  genderq_favT3 "\quad GQ x Favored"						///
						  mixq_favT3 "\quad MIX x Favored"				///
						  favoredT3 "\quad Favored" 				///
						  beliefT3 "\quad Belief on rank" 	///
						  risk "\quad Risk measure"	)		///
						order(genderq mixq genderq_favT3 mixq_favT3 favoredT3 beliefT3 risk) ///
						star(* 0.10 ** 0.05 *** 0.01)			///
						  se  b(3) ar2 compress noeqlines replace
					 
				*Export Table B.1
					esttab mT3*	///
						using probitWTC_all.tex, ///
						varlabels(								///
						  genderq "\quad GQ"					///
						  mixq "\quad MIX "					///
						  genderq_favT3 "\quad GQ x Favored"						///
						  mixq_favT3 "\quad MIX x Favored"				///
						  favoredT3 "\quad Favored" 				///
						  beliefT3 "\quad Belief on rank" 	///
						  risk "\quad Risk measure"			///
						  risk_favT3 "\quad Risk measurexFavored" ///
						  fairness "\quad Fairness perception" ///
						  CRT_belief "\quad Belief on CRT score" ///
						  goodinmath "\quad Belief on math ability" ) ///
						order(genderq mixq genderq_favT3 mixq_favT3 favoredT3 beliefT3 ///
						   risk risk_favT3 fairness CRT_belief goodinmath)						///
						   star(* 0.10 ** 0.05 *** 0.01)			///
						 se b(3) ar2 compress noeqlines replace
					eststo clear

		*Table 2 and B.2: The effect of quotas on beliefs
				*Specification 1:
					reg beliefT3 i.treatment correctT3, first vce(cluster uGroup)
					eststo beT3_1
				*Specification 2: 
					reg beliefT3 i.treatment correctT3 fairness like_mathtask fieldofstudy goodinmath, first vce(cluster uGroup)
					eststo beT3_2
				*Specification 3:
					reg beliefT3 i.treatment#i.favoredT3 correctT3 fairness like_mathtask fieldofstudy goodinmath, first vce(cluster uGroup)
					eststo beT3_3
				*Specification 4:
					reg beliefT3 i.treatment#i.gender correctT3, first vce(cluster uGroup)
					eststo beT3_4
					*test of equivalent of coefficients
					test _b[2.treatment#1.gender] = _b[1.treatment#1.gender], constant
					test _b[2.treatment#1.gender] = _b[3.treatment#1.gender], constant 
					test _b[1.treatment#1.gender] = _b[3.treatment#1.gender], constant
				*Specification 5:
					reg beliefT3 i.treatment#i.gender correctT3 fairness like_mathtask fieldofstudy goodinmath, first vce(cluster uGroup)
					eststo beT3_5
					*test of equivalent of coefficients
					test _b[2.treatment#1.gender] = _b[1.treatment#1.gender], constant
					test _b[2.treatment#1.gender] = _b[3.treatment#1.gender], constant 
					test _b[1.treatment#1.gender] = _b[3.treatment#1.gender], constant
			
				*Export tables
					*cd "xxx\Tables"
					esttab beT3_*	///
					   using beT3_all.tex, ///
						varlabels(					///
						  genderq "\quad GQ"		///
						  mixq"\quad MIX "			///
						  correctT3 "\quad Stage 3 Performance" 	///
						  fairness "\quad Fairness perception" ///
						  goodinmath "\quad Belief on math ability"  ///
						  like_mathtask "\quad Like mathtask" 	///
						  fieldofstudy "\quad Field of study") 	///
						star(* 0.10 ** 0.05 *** 0.01)			///
						se  b(3) r2 compress noeqlines replace
					eststo clear
		
		*Section B.4
				bys treatment: sum beliefT3 if gender==0
				ranksum beliefT3 if (gender==0 & treatment == 1) | (gender==0 & treatment == 2), by(treatment)
				ranksum beliefT3 if (gender==0 & treatment == 3) | (gender==0 & treatment == 2), by(treatment)
				
				bys treatment: sum  beliefT3 if gender==1
				ranksum beliefT3 if (gender==1 & treatment == 1) | (gender==1 & treatment == 2), by(treatment)
				ranksum beliefT3 if (gender==1 & treatment == 3) | (gender==1 & treatment == 2), by(treatment)
				
				bys treatment: sum correctT3 if favoredT3==1
				bys treatment: sum correctT3 if gender==0
				ranksum beliefT2 if (favoredT2==1 & treatment == 3) | (gender==0 & treatment == 2), by(treatment)
							
				bys treatment: sum correctT3 if gender==0
				bys treatment: sum correctT3 if favoredT3==1

				ranksum correctT3 if  (gender==0 & treatment == 2) | (favoredT3==1 & treatment == 3), by(treatment)
				ranksum correctT3 if  (gender==0 & treatment == 2) | (gender==0 & treatment == 3), by(treatment)
				
				
//______________________________________________________________________________
//Section 4.3. POST-COMPETITION COOPERATION_____________________________________
//______________________________________________________________________________
	
	*Team selection
		*Note: Results reported in Appendix B.5
	
		*Figure B.4
			graph dot Num_voteleader Num_voteleader_byMen Num_voteleader_byWomen if isLeader==1,//
				  vertical over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  yscale (range(0(1)4)) ytitle ("Number of votes") //left graph
			graph dot Num_votecol Num_votecol_byMen Num_votecol_byWomen if isLeader==0, //
				  vertical over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  yscale (range(0(1)4)) ytitle ("Number of votes") //right graph
				  
		*Figure B.4 notes
			bys treatment gender: sum Num_voteleader if isLeader==1
			ranksum Num_voteleader if (gender==0 & isLeader==1&treatment == 1 ) | (gender==1 & isLeader==1&treatment == 1 ), by(gender)
			ranksum Num_voteleader if (gender==0 & isLeader==1&treatment == 2) | (gender==1 & isLeader==1&treatment == 2), by(gender)
			ranksum Num_voteleader if (gender==0 & isLeader==1& treatment == 3) | (gender==1 & isLeader==1&treatment == 3), by(gender)
			
			bys treatment gender: sum Num_votecol if isLeader==0
			ranksum Num_votecol if (gender==0 & isLeader==0 &treatment == 1 ) | (gender==1 & isLeader==1&treatment == 1 ), by(gender)
			ranksum Num_votecol if (gender==0 & isLeader==0&treatment == 2) | (gender==1 & isLeader==1&treatment == 2), by(gender)
			ranksum Num_votecol if (gender==0 & isLeader==0& treatment == 3) | (gender==1 & isLeader==1&treatment == 3), by(gender)

		*Votes leader green versus blue in MIX
			bys Luck: sum Num_voteleader if isLeader==1 & treatment==3
			ranksum Num_voteleader if (Luck==0 & isLeader==1& treatment == 3) | (Luck==1 & isLeader==1&treatment == 3), by(Luck)

			bys treatment: sum Num_voteleader if isLeader==1 & Luck==1			
			ranksum Num_voteleader if (Luck==1 & isLeader==1& treatment == 1) | (Luck==1 & isLeader==1&treatment == 3), by(treatment)
			ranksum Num_voteleader if (Luck==1 & isLeader==1& treatment == 2) | (Luck==1 & isLeader==1&treatment == 3), by(treatment)

		*Composition of votes
			bys treatment gender: sum Num_voteleader_byWomen Num_voteleader_byMen if isLeader==1
		
		*Table B.3: Composition of leaders
			bys treatment: tab L1_gender L2_gender
			
		*Figure B.5
			graph dot Num_voteleader Num_voteleader_byMen Num_voteleader_byWomen if isLeader==1 & Leader_1male1female==1, //
				  vertical over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) yscale (range(0(1)4)) ytitle ("Number of votes") //left graph
			graph dot Num_votecol Num_votecol_byMen Num_votecol_byWomen if Leader_1male1female==1 &isLeader==0, //
				  vertical over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) yscale (range(0(1)4)) ytitle ("Number of votes") //right graph
			
		* Votes in groups with one male and one female leader
			bys treatment gender: sum Num_voteleader if isLeader==1 & Leader_1male1female==1
			ranksum Num_voteleader if (gender==0 & isLeader==1& treatment == 1&Leader_1male1female==1) | (gender==1 & isLeader==1&treatment == 1&Leader_1male1female==1), by(gender)
			ranksum Num_voteleader if (gender==0 & isLeader==1&treatment == 2&Leader_1male1female==1) | (gender==1 & isLeader==1&treatment == 2&Leader_1male1female==1), by(gender)
			ranksum Num_voteleader if (gender==0 & isLeader==1&treatment == 3&Leader_1male1female==1) | (gender==1 & isLeader==1&treatment == 3&Leader_1male1female==1), by(gender)
			
			bys treatment gender: sum Num_votecol if isLeader==0 & Leader_1male1female==1
			ranksum Num_votecol if (gender==0 & isLeader==0&treatment == 1&Leader_1male1female==1)|(gender==1 & isLeader==0&treatment == 1&Leader_1male1female==1), by(gender)
			ranksum Num_votecol if (gender==0 & isLeader==0&treatment == 2&Leader_1male1female==1)|(gender==1 & isLeader==0&treatment == 2&Leader_1male1female==1), by(gender)
			ranksum Num_votecol if (gender==0 & isLeader==0&treatment == 3&Leader_1male1female==1)|(gender==1 & isLeader==0&treatment == 3&Leader_1male1female==1), by(gender)
	
	*Performance in team and the cost of misselection
		*Note: Results reported in Appendix B.6
		
		*Figure B.6
			graph box correctT5, over(gender,relabel(0 "Women" 1 "Men")) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //
				  ytitle ("Number of correct answers")
		
		*Performance in grid task
			bys treatment: sum correctT5
			kwallis correctT5, by(treatment)
			
			bys treatment gender: sum correctT5
			kwallis correctT5 if gender==0, by(treatment)
			kwallis correctT5 if gender==1, by(treatment)
			
			ranksum correctT5 if (gender==0 & treatment == 1) | (gender==1 &treatment == 1), by(gender)
			ranksum correctT5 if  (gender==0 &treatment == 2) | (gender==1 &treatment == 2), by(gender)
			ranksum correctT5 if  (gender==0 &treatment == 3) | (gender==1 &treatment == 3), by(gender)
			
		*Figure B.7
			graph bar diff_group_performanceratio diff_leader_performanceratio diff_colleague_performanceratio, //
				  over(gender)  over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) ytitle ("Ratio") 
				  
		*Inefficiency due to misselection
			bys treatment: sum diff_group_performanceratio
			ranksum diff_group_performanceratio if (treatment == 1) | (treatment == 2), by(treatment)
			ranksum diff_group_performanceratio  if  ( treatment == 2) | (treatment == 3), by(treatment)
			ranksum diff_group_performanceratio if  (treatment == 1) | (treatment == 3), by(treatment)
			
			bys treatment: sum diff_colleague_performanceratio
			ranksum diff_colleague_performanceratio if (treatment == 1) | (treatment == 2), by(treatment)
			ranksum diff_colleague_performanceratio  if  ( treatment == 2) | (treatment == 3), by(treatment)
			ranksum diff_colleague_performanceratio if  (treatment == 1) | (treatment == 3), by(treatment)
			
			bys treatment: sum diff_leader_performanceratio
			ranksum diff_leader_performanceratio if (treatment == 1) | (treatment == 2), by(treatment)
			ranksum diff_leader_performanceratio  if  ( treatment == 2) | (treatment == 3), by(treatment)
			ranksum diff_leader_performanceratio if  (treatment == 1) | (treatment == 3), by(treatment)
			
			bys treatment gender: sum diff_leader_performanceratio
			ranksum diff_leader_performanceratio if  (gender==0 & treatment == 1) | (gender==0 & treatment == 3), by(treatment)
			ranksum diff_leader_performanceratio if  (gender==1 & treatment == 1) | (gender==1 & treatment == 3), by(treatment)

			ranksum diff_leader_performanceratio if (gender==0 & treatment == 1) | (gender==0 & treatment == 2), by(treatment)
			ranksum diff_leader_performanceratio if (gender==1 & treatment == 1) | (gender==1 & treatment == 2), by(treatment)

						
	
//______________________________________________________________________________
//Section B.2.FAIRNESS PERCEPTION_______________________________________________
//______________________________________________________________________________
		
	*Figure B.3
		gen type4=1 if type==4 //nonfavored in MIX
		replace type4=0 if type4==. //favored in MIX

		graph bar fairness_CTR fairness_gender fairness_mix, over(gender) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) //left graph
		graph bar fairness_CTR fairness_gender fairness_mix, over(type4) over(treatment, relabel(1 "CTR" 2 "GQ" 3 "MIX")) // right graph
		
	*Women perceive gender quotas as fairer than men in all treatment
		ranksum fairness_gender if (gender==0 & treatment == 1) | (gender==1 & treatment == 1), by(gender)
		ranksum fairness_gender if (gender==0 & treatment == 2) | (gender==1 & treatment == 2), by(gender)
		ranksum fairness_gender if (gender==0 & treatment == 3) | (gender==1 & treatment == 3), by(gender)
	
	*The gender gap in fairness perception for gender quotas 
		bys treatment gender: sum fairness_gender
		
		ranksum fairness_gender if (gender==0 & treatment == 1) | (gender==0 & treatment == 2), by(treatment)
		ranksum fairness_gender if (gender==0 & treatment == 3) | (gender==0 & treatment == 2), by(treatment)
		ranksum fairness_gender if (gender==0 & treatment == 1) | (gender==0 & treatment == 3), by(treatment)

		ranksum fairness_gender if (gender==1 & treatment == 1) | (gender==1 & treatment == 2), by(treatment)
		ranksum fairness_gender if (gender==1 & treatment == 1) | (gender==1 & treatment == 3), by(treatment)
		ranksum fairness_gender if (gender==1 & treatment == 3) | (gender==1 & treatment == 2), by(treatment)

				
		
//______________________________________________________________________________
//Section B.7.POWER ANALYSIS____________________________________________________
//______________________________________________________________________________		
	
	* Sample size
		/*The key outcome per the pre-registration is the proportions of affirmed and unaffirmed subjects selecting competitions. 
			This proportion is taken from literature. In particular, from Balafoutas's and Sutter's 2012 paper titled
			"Affirmative Action Policies Promote Women and Do Not Harm Efficiency in the Laboratory." Science 335 (6068):579–582 
			One of the result states "The relative frequency of women opting for competition increases from 30.6% in CTR to 52.8% in QUO" */
		
		power twoprop .306  .528, power(0.8) alpha(0.05) // N=77
		
		
	* Efficiency
		*All subjects
			bys treatment: sum correctT3  // CTR mean=10.10, differences are small
			*CTR vs. GQ
			power twomeans 10.90909 , n1(66) n2(84) sd1(3.968054) sd2(4.137534) power(0.8) alpha(0.05) //can detect difference of 1.88, about 17.2% of CTR mean
			*CTR vs. MIX
			power twomeans 10.90909 , n1(66) n2(90) sd1(3.968054) sd2(4.126647) power(0.8) alpha(0.05) //can detect difference of 1.84, about 16.9% of CTR mean
			
		*Winners
			bys treatment: sum correctT3 if  WINT3_ALL==1 // CTR mean=14.88
			*CTR vs. GQ
			power twomeans 14.875 , n1(16) n2(20) sd1(3.703602) sd2(3.248886) power(0.8) alpha(0.05) //can detect difference of 3.41, about 22.9% of CTR mean
			*CTR vs. MIX
			power twomeans 14.875 , n1(16) n2(26) sd1(3.703602) sd2(4.338025) power(0.8) alpha(0.05) //can detect difference of 3.62, about 24.3% of CTR mean
		
		
	* Willingness to compete
		*All subjects
			bys treatment: sum choiceT3 // CTR mean=0.55
			*CTR vs GQ
				power twoprop .5454545, n1(66) n2(84) power(0.8) alpha(0.05) //can detect difference of 0.2167, 39.7% of CTR mean
			*CTR vs MIX
				power twoprop .5454545, n1(66) n2(90) power(0.8) alpha(0.05) //can detect difference of 0.2135, 39.1% of CTR mean
			
		*By gender 
			*Women
				bys treatment: sum choiceT3 if gender ==0 // CTR mean=0.42
				*CTR vs GQ
					power twoprop .4242424, n1(33) n2(42) power(0.8) alpha(0.05) //can detect difference of 0.3154, 74.3% of CTR mean
				*CTR vs MIX
					power twoprop .4242424, n1(33) n2(45) power(0.8) alpha(0.05) //can detect difference of 0.3109, 73.3% of CTR mean
			
			*Men
				bys treatment: sum choiceT3 if gender==1 // CTR mean=0.67
				*CTR vs GQ
					power twoprop .6666667, n1(33) n2(42) power(0.8) alpha(0.05) //can detect difference of 0.2561, 38.4% of CTR mean
				*CTR vs MIX
					power twoprop .6666667, n1(33) n2(45) power(0.8) alpha(0.05) //can detect difference of 0.2525, 37.9% of CTR mean
			
			
	* Self-confidence (belief on ranks in Stage 3)
		*All subjects
			bys treatment: sum beliefT3 // CTR mean=2.70
			*CTR vs. GQ
				power twomeans 2.69697 , n1(66) n2(84) sd1(1.288645) sd2(1.451995) power(0.8) alpha(0.05) //can detect difference of 0.63, about 23.4% of CTR mean
			*CTR vs. MIX
				power twomeans 2.69697 , n1(66) n2(90) sd1(1.288645) sd2(1.330709) power(0.8) alpha(0.05) //can detect difference of 0.60, about 22.1% of CTR mean
			
		*By gender 
			*Women
				bys treatment: sum beliefT3 if gender ==0 // CTR mean=1.38
				*CTR vs GQ
					power twomeans 2.969697, n1(33) n2(42) sd1(1.380327) sd2(1.303083) power(0.8) alpha(0.05) //can detect difference of 0.8906, 30.0% of CTR mean
				*CTR vs MIX
					power twomeans 2.969697, n1(33) n2(45) sd1(1.380327) sd2(1.3484) power(0.8) alpha(0.05) //can detect difference of 0.8903, 30.0% of CTR mean
			
			*Men
				bys treatment: sum beliefT3 if gender==1 // CTR mean=2.42
				*CTR vs GQ
					power twomeans 2.424242, n1(33) n2(42) sd1(1.14647) sd2(1.598671) power(0.8) alpha(0.05) //can detect difference of 0.9010, 37.2% of CTR mean
				*CTR vs MIX
					power twomeans 2.424242, n1(33) n2(45) sd1(1.14647) sd2(1.324593 ) power(0.8) alpha(0.05) //can detect difference of 0.7970, 32.9% of CTR mean
			
	*Team selection
		*Votes for leader - all subjects
			bys treatment: sum Num_voteleader if isLeader==1 // CTR mean=1.31
			*CTR vs. GQ
				power twomeans 2 , n1(22) n2(28) sd1(1.309307) sd2(1.333333) power(0.8) alpha(0.05) //can detect difference of 1.08, 54.0% of CTR mean
			*CTR vs. MIX
				power twomeans 2 , n1(22) n2(30) sd1(1.309307) sd2(1.082781) power(0.8) alpha(0.05) //can detect difference of 0.98, about 49.1% of CTR mean
			
		*Votes for leader - by treatment 
			*CTR: Men vs women
				bys gender: sum Num_voteleader if isLeader==1 & treatment==1 // ctr group mean=1.56
				power twomeans 1.545455, n1(11) n2(11) sd1(1.29334) sd2(1.21356) power(0.8) alpha(0.05) //can detect difference of 1.58, 102.2% of mean of female group
			*GQ: Men vs women
				bys gender: sum Num_voteleader if isLeader==1 & treatment==2 // ctr group mean=1.31
				power twomeans 1.3125, n1(16) n2(12) sd1(1.078193) sd2(1.083625) power(0.8) alpha(0.05) //can detect difference of 1.21, 92.2% of mean of female group
			*MIX: Men vs women
				bys gender: sum Num_voteleader if isLeader==1 & treatment==3 // ctr group mean=1.75
				power twomeans 1.75, n1(16) n2(12) sd1(1.064581) sd2(1.069045) power(0.8) alpha(0.05) //can detect difference of 1.19, 68.0% of mean of female group
			*MIX: Green vs Blue
				bys Luck: sum Num_voteleader if isLeader==1 & treatment==3 // ctr group mean=1.8
				power twomeans 1.8, n1(15) n2(15) sd1(1.082326) sd2(1.082326) power(0.8) alpha(0.05) //can detect difference of 1.15, 81.7% of mean of Blue group
			
		*Votes for colleague
			bys treatment: sum Num_votecol if isLeader==0 // CTR mean=2
			*CTR vs. GQ
				power twomeans 2 , n1(44) n2(56) sd1(1.293993) sd2(1.29334) power(0.8) alpha(0.05) //can detect difference of 0.74, 37% of CTR mean
			*CTR vs. MIX
				power twomeans 2 , n1(44) n2(60) sd1(1.293993) sd2(1.22128) power(0.8) alpha(0.05) //can detect difference of 0.71, 35.5% of CTR mean
			
		*Votes for colleagues - by treatment
			bys gender: sum Num_votecol if isLeader==0 & treatment==1 // ctr group mean=1.5
			*CTR: Men vs women 
				power twomeans 1.5, n1(22) n2(22) sd1(1.185227) sd2(1.224745) power(0.8) alpha(0.05) //can detect difference of 1.04, 69.5% of mean of female group
			*GQ: Men vs women
				bys gender: sum Num_votecol if isLeader==0 & treatment==2 // ctr group mean=1.38
				power twomeans 1.384615, n1(26) n2(30) sd1(1.09825) sd2(1.224276) power(0.8) alpha(0.05) //can detect difference of 0.89, 64.3% of mean of female group
			*MIX: Men vs women
				bys gender: sum Num_votecol if isLeader==0 & treatment==3 // ctr group mean=1.56
				power twomeans  1.551724, n1(29) n2(31) sd1(.9481639) sd2(1.310832) power(0.8) alpha(0.05) //can detect difference of 0.8385, 54.0% of mean of female group
			*MIX: Green vs Blue
				bys Luck: sum Num_votecol if isLeader==0 & treatment==3 // ctr group mean=1.87
				power twomeans 1.866667, n1(30) n2(30) sd1(1.279368) sd2(1.166585) power(0.8) alpha(0.05) //can detect difference of 0.90, 48.2% of mean of Blue group
		
		
	*Teamwork performance
		bys treatment: sum correctT5 // CTR mean=6.78
		*CTR vs. GQ
			power twomeans 6.772727 , n1(66) n2(84) sd1(3.171001) sd2(2.911464) power(0.8) alpha(0.05) //can detect difference of 1.42, about 21% of CTR mean
		*CTR vs. MIX
			power twomeans 6.772727 , n1(66) n2(90) sd1(3.171001) sd2(3.104284) power(0.8) alpha(0.05) //can detect difference of 1.44, about 21.3% of CTR mean
			
			
**********************THE END***************************************************
